#include<iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define MAXN 20000
int N,res,r[MAXN][4],i,j;
bool marked[MAXN];

int main(){
	while(cin>>N){
		for(int i=0;i<N;i++){
			scanf("%d %d %d %d",&r[i][0],&r[i][1],&r[i][2],&r[i][3]);
		}
		memset(marked,false,sizeof(marked));
		res = 0;
		for(i=0;i<N-1 && res<N;i++){
		    for(j=i+1;j<N && res<N;j++){
				if(!marked[j] && r[i][0] <= r[j][0] && r[i][2] <= r[j][2]){
					if(r[i][1] >=r[j][1] && r[i][3] >=r[j][3]){
						marked[j] = true;
						res++;
					}
				}
				if(!marked[i] && r[i][0] >= r[j][0] && r[i][2] >= r[j][2]){
					if (r[i][1] <=r[j][1] && r[i][3] <=r[j][3]){
				    	marked[i] = true;
						res++;
					}
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}
